<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: shop_content.php 515 2015-02-27 13:18:38Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 515 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2015-02-27 13:18:38 +0000 (Fri, 27 Feb 2015) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */
define('GLOBAL_COLUMN_LEFT', '0');
require ('includes/application_top.php');

$smarty = new Smarty();

require_once (DIR_FS_INC.'inc.validate_email.php');
require_once (DIR_FS_INC.'inc.add_js_plugin.php');

if(GROUP_CHECK == 'true')
	$group_check = " AND group_ids LIKE '%c_".$_SESSION['customers_status']['customers_status_id']."_group%'";

$CACHE_CONTENT_ID = '';

$shop_content_data = $db->db_query("SELECT
										content_id,
										content_title,
										content_heading,
										content_text,
										content_file,
										content_show_pdf,
										content_show_print,
										content_show_back
									FROM
										".TABLE_CONTENT_MANAGER."
									WHERE
										content_group = '".(int)$_GET['coID']."' ".$group_check."
									AND
										languages_id = '".(int)$_SESSION['languages_id']."'", true);
$breadcrumb->add($shop_content_data->fields['content_title'], href_link(FILENAME_CONTENT,'coID='.(int) $_GET['coID']));

if ($_GET['coID'] != 7)
	require (DIR_WS_INCLUDES.'header.php');
	
if ($_GET['coID'] == 7 && $_GET['action'] == 'success')
	require (DIR_WS_INCLUDES.'header.php');

$smarty->assign('CONTENT_HEADING', $shop_content_data->fields['content_heading']);

if ($_GET['coID'] == 7) {
	if(!defined('GLOBAL_COLUMN_LEFT')) define('GLOBAL_COLUMN_LEFT', '0');
	include(DIR_FS_DOCUMENT_ROOT.'media'.DS.'content'.DS.'contact_us.php');
}
else {
	if($shop_content_data->fields['content_show_pdf'] == 1)
		$smarty->assign('PDF_LINK','<a href="'.href_link(FILENAME_PRINT_PDF,'content='.$_GET['coID']).'">'.image('images/button_pdf.gif',IMAGE_BUTTON_PRINT_PDF).'</a>');

	if($shop_content_data->fields['content_show_print'] == 1)
		$smarty->assign('PRINT_LINK','<a href="javascript:popupWindowShipping(\''.href_link(FILENAME_POPUP_CONTENT,'coID='.$_GET['coID']).'\')">'.image('images/button_print.gif',IMAGE_BUTTON_PRINT_CONTENT).'</a>');

	if($shop_content_data->fields['content_show_back'] == 1)
		$smarty->assign('BUTTON_CONTINUE', '<a class="mt10" href="javascript:history.back(1)">'.image_button('button_back.gif', IMAGE_BUTTON_BACK).'</a>');

	if ($shop_content_data->fields['content_file'] != '') {
		ob_start();
		if (strpos($shop_content_data->fields['content_file'], '.txt'))
			echo '<pre>';
		include (DIR_FS_CATALOG.'media/content/'.$shop_content_data->fields['content_file']);
		if (strpos($shop_content_data->fields['content_file'], '.txt'))
			echo '</pre>';
		if (strpos($shop_content_data->fields['content_file'], '.htm')) {
    	$content_body = utf8_encode(ob_get_contents());
    }
    else {
    	$content_body = ob_get_contents();
  		$smarty->assign('file', $content_body);
  	}
		ob_end_clean();

	} else
		$content_body = $shop_content_data->fields['content_text'];

	if (preg_match_all('/{\$MODULE_([a-z|A-Z|_]+)}/', $content_body, $matches, PREG_OFFSET_CAPTURE)) {
		$module_smarty = new Smarty();
		$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');

		for($idx = 0; $idx < count($matches[0]); $idx++) {
			$module_file_name = DIR_WS_MODULES.$matches[1][$idx][0].'.php';
			if (file_exists($module_file_name)) {
				include($module_file_name);
				$content_body = str_replace($matches[0][$idx], $main_content, $content_body);
			}
		}
	}

	require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');

	$smarty->assign('CONTENT_BODY', $content_body);
  $smarty->assign('language', $_SESSION['language']);

//	echo_e($smarty->getTemplateVars(), 'e');
	// set cache ID
	 if (!CacheCheck()) {
		$smarty->caching = false;
		$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/content.html');
	} else {
		$smarty->caching = true;
		$smarty->cache_lifetime = CACHE_LIFETIME;
		$smarty->cache_modified_check = CACHE_CHECK;
		$cache_id = $_SESSION['language'].'_'.$_SESSION['customers_status']['customers_status_id'].'_'.$shop_content_data->fields['content_id'].'id'.$CACHE_CONTENT_ID;
		$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/content.html', $cache_id);
	}
}
//die($main_content);
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = false;
$smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');